package com.lc202310;

/**
 * Description:
 *
 * @Create 2023/10/10 22:59
 * @Version 1.0
 */
public class Solution389 {
    public char findTheDifference1(String s, String t) {
        int[] arr = new int[26];
        for (int i = 0; i < s.length(); i++) {
            arr[s.charAt(i) - 'a'] += 1;
        }
        for (int i = 0; i < t.length(); i++) {
            arr[t.charAt(i) - 'a'] -= 1;
            if (arr[t.charAt(i) - 'a'] < 0) {
                return t.charAt(i);
            }
        }
        return ' ';
    }

    public char findTheDifference(String s, String t) {
        int[] arr = new int[26];
        int length = s.length();
        for (int i = 0; i < length; i++) {
            arr[s.charAt(i) - 'a'] += 1;
            arr[t.charAt(i) - 'a'] -= 1;
        }
        arr[t.charAt(length) - 'a'] -= 1;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] < 0) {
                return (char) ('a' + i);
            }
        }
        return ' ';
    }
}
